import { ApiProperty } from '@nestjs/swagger'
import { IsNotEmpty, IsDefined, IsInt, IsString, IsEmail } from 'class-validator'
import { PageDto } from '../../common/dto/dto'

/*
 * @Author: fhw
 * @Date: 2022-07-31 12:42:38
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-02-04 00:00:17
 * @Description:
 */
export class CommentPageDto extends PageDto {
  @IsNotEmpty({ message: '文章id不能为空' })
  @IsDefined({ message: '文章id不能为空' })
  @ApiProperty({
    type: Number,
    name: 'articleId',
    description: 'articleId',
  })
  public readonly articleId: number
}
export class CommentInfoIdDto {
  // @IsNotEmpty({ message: 'id不能为空' })
  // @IsInt({ message: 'id不是整数' })
  // @IsDefined({ message: 'id不能为空' })
  // @ApiProperty({
  //   type: Number,
  //   name: 'id',
  //   description: 'id',
  // })
  // public readonly id: number
  @ApiProperty({
    type: Number,
    name: 'id',
    description: 'id',
  })
  public readonly id: number

  @ApiProperty({
    type: String,
    name: 'content',
    description: '评论内容',
  })
  public readonly content?: string

  @ApiProperty({
    type: Number,
    name: 'userId',
    description: '用户id',
  })
  public readonly userId?: number
}
export class CommentDto {

  @IsNotEmpty({ message: '文章id不能为空' })
  @IsInt({ message: '文章id不是整数' })
  @IsDefined({ message: '文章id不能为空' })
  @ApiProperty({
    type: Number,
    name: 'articleId',
    description: '文章id',
  })
  public readonly articleId: number

  @IsDefined({ message: '评论内容不能为空' })
  @IsNotEmpty({ message: '评论内容不能为空' })
  @IsString({ message: '评论内容不是String类型' })
  @ApiProperty({
    type: String,
    name: 'content',
    description: '评论内容',
  })
  public readonly content?: string

  @IsDefined({ message: '用户id不能为空' })
  @IsNotEmpty({ message: '用户id不能为空' })
  @IsInt({ message: '用户id不是整数' })
  @ApiProperty({
    type: Number,
    name: 'userId',
    description: '用户id',
  })
  public readonly userId?: number

  @ApiProperty({
    type: Number,
    name: 'toUserId',
    description: '评论用户id',
  })
  public readonly toUserId?: number
  @ApiProperty({
    type: Number,
    name: 'commentId',
    description: '评论id',
  })
  public readonly commentId?: number
}
